说明:以下脚本在Ubuntu 18.04运行通过,大部分脚本执行需要管理员权限。
1. 准备docker环境
# 安装必备工具包
apt-get -y install apt-transport-https ca-certificates curl software-properties-common
# 添加docker阿里云源,相对官方源速度更快
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
# 安装最新版社区版docker
apt update -y
apt install -y docker-ce
# 如果想要安装指定版本的docker-ce,如下:
# 查看有哪些版本
apt-cache madison docker-ce
# 安装指定版本
apt install -y docker-ce=[版本]
# 设置阿里云docker源
mkdir -p /etc/docker
tee /etc/docker/daemon.json |